package ovm.application;

import ovm.gui.*;
import com.vaadin.Application;

public class MainApplication extends Application {

    public static Navigator navigator = null;

    @Override
    public void init() {
        if (getWindow("authorization") != null) {
            this.removeWindow(getWindow("authorization"));
        }

        AuthorizationWindow authorizationWindow = new AuthorizationWindow();
        authorizationWindow.setName("authorization");

        setMainWindow(authorizationWindow);

        authorizationWindow.draw();
        authorizationWindow.setApplication(this);

        setLogoutURL("/authorization");

    }

    public void createNavigator(int user) {
        if (getWindow("main") != null) {
            this.removeWindow(getWindow("main"));
        }
        navigator = new Navigator(user);
        navigator.setName("main");

        addWindow(navigator);

        navigator.draw();
        navigator.setApplication(this);
    }

}
